<template>
  <a-modal title="风险排查任务" width="60%" :visible="visible" @ok="handleCancel" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
    <BasicTable
      :columns="columns"
      :dataSource="recordList"
      :canResize="canResize"
      :loading="loading"
      :striped="striped"
      :bordered="border"
      :pagination="pagination"
    >
    </BasicTable>
  </a-modal>
</template>

<script lang="ts" setup>
  import { ref, nextTick, defineExpose } from 'vue';
  import { baseMeasuresTaskRecordList } from '../analysisData.api';
  import { BasicTable } from '/@/components/Table';
  
  const visible = ref<boolean>(false);
  const disableSubmit = ref<boolean>(false);
  const emit = defineEmits(['register', 'success']);
  const canResize = ref(false);
  const loading = ref(false);
  const striped = ref(true);
  const border = ref(true);
  const pagination = ref<any>(false);
  const recordList = ref<any>(false);
  const columns =[
    {
      title: '装置',
      dataIndex: 'riskDeviceId_dictText',
    },
    {
      title: '单元',
      dataIndex: 'riskUnitId_dictText',
    },
    {
      title: '管控措施描述',
      dataIndex: 'riskMeasureDesc',
    },
    {
      title: '隐患排查内容',
      dataIndex: 'troubleshootOntent',
    },
    {
      title: '排查人',
      dataIndex: 'identifyPeople_dictText',
    },
    {
      title: '任务开始时间',
      dataIndex: 'taskStartTime',
      sorter: true,
    },
    {
      title: '排查结果',
      dataIndex: 'period',
    },
    {
      title: '排查周期',
      dataIndex: 'checkStatus_dictText',
    },
    {
      title: '周期单位',
      dataIndex: 'periodUnit_dictText',
    },
  ];
  
  /**
   * 编辑
   * @param params
   */
  function edit(params) {
    visible.value = true;
    nextTick(() => {
      baseMeasuresTaskRecordInit(params);
    });
  }
  
  async function baseMeasuresTaskRecordInit(params){
    await baseMeasuresTaskRecordList(params)
      .then((responseResult) => {
        recordList.value = responseResult.records;
      })
  };

  /**
   * 取消按钮回调事件
   */
  function handleCancel() {
    visible.value = false;
  }

  defineExpose({
    edit,
    disableSubmit,
    baseMeasuresTaskRecordInit,
  });
</script>

<style>
  /**隐藏样式-modal确定按钮 */
  .jee-hidden {
    display: none !important;
  }
</style>
